package com.ly.order.base;

import com.ass.rocketmq.base.AbstractMessageQueueSelector;
import com.ass.rocketmq.base.QueueSelectorFunction;
import org.apache.rocketmq.common.message.Message;
import org.apache.rocketmq.common.message.MessageQueue;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
public class OrderMessageQueueSelector extends AbstractMessageQueueSelector {


    //例子
    // 现在没啥办法能将业务和mq的东西 完全抽离开
    @Override
    protected QueueSelectorFunction<List<MessageQueue>, Message, Object, MessageQueue> doQueueSelector() {
        return (x,y,z)->{
            Integer id = (Integer) z;
            int index = id % x.size();
            return x.get(index);
        };
    }
}
